﻿CREATE PROCEDURE [dbo].[MarkEntriesAsBilled]
@ProjectID INT, @StartDate DATETIME=NULL, @EndDate DATETIME
AS
IF @StartDate IS NULL SET @StartDate = CONVERT(DATETIME, '1/1/2000')

 

UPDATE	EntryLog 
SET		HasBeenBilled = 1, BillingStateID = 3
WHERE	ProjectID = @ProjectID AND EntryDate BETWEEN @StartDate AND @EndDate AND BillingStateID = 2

UPDATE	Projects 
SET		BilledAsOf = @EndDate
WHERE	ProjectID = @ProjectID

